package com.example.musicbox.controller;


import com.example.musicbox.entity.MCatalogue;
import com.example.musicbox.service.impl.MCatalogueServiceImpl;
import com.example.musicbox.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 帅哥是我
 * @since 2022-08-01
 */
@RestController
@RequestMapping("/m-catalogue")
public class MCatalogueController {

    @Resource
    private MCatalogueServiceImpl mCatalogueService;


    /**
     * @api {POST} /m-catalogue/addMCatalogue 添加目录
     * @apiVersion 1.0.0
     * @apiGroup 目录控制器
     * @apiName 添加目录
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * token=STw
     * @apiParam (请求体) {Number} mid
     * @apiParam (请求体) {Number} uid
     * @apiParam (请求体) {Number} cSort
     * @apiParam (请求体) {String} cName
     * @apiParam (请求体) {Array} musicList 音乐列表不存在与目录中，方便查询添加
     * @apiParam (请求体) {Number} musicList.mid
     * @apiParam (请求体) {String} musicList.mname
     * @apiParam (请求体) {String} musicList.mauthor
     * @apiParam (请求体) {Number} musicList.uid
     * @apiParam (请求体) {String} musicList.murl
     * @apiParam (请求体) {Number} musicList.msecond
     * @apiParam (请求体) {String} musicList.mstatus
     * @apiParam (请求体) {String} musicList.ispublish
     * @apiParam (请求体) {String} musicList.coverby
     * @apiParam (请求体) {String} musicList.mvurl
     * @apiParam (请求体) {Number} musicList.praisecount
     * @apiParam (请求体) {Number} musicList.praiseuserid
     * @apiParam (请求体) {String} musicList.praiseusername
     * @apiParam (请求体) {Number} musicList.listenuserid
     * @apiParam (请求体) {Number} musicList.listencount
     * @apiParam (请求体) {Number} musicList.downloadcount
     * @apiParam (请求体) {Number} musicList.needlevel
     * @apiParam (请求体) {Number} musicList.mType
     * @apiParam (请求体) {Object} musicList.uploadDate
     * @apiParamExample 请求体示例
     * {"uid":71,"cName":"Gn5gGHBr","mid":6242,"cSort":3665,"musicList":[{"msecond":1128,"listenuserid":4332,"mid":897,"mstatus":"p8Ku","praisecount":3613,"mname":"o6zRX3","mauthor":"BpOs","coverby":"1weB1s","mType":9881,"uid":6651,"murl":"2x3uxMQ","mvurl":"FdSKP","ispublish":"WO","needlevel":5770,"praiseusername":"2","listencount":1595,"downloadcount":7787,"praiseuserid":2152}]}
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/addMCatalogue")
    public Result addMCatalogue(@RequestBody MCatalogue mCatalogue,@RequestHeader String token)
    {
        Result result = mCatalogueService.addMCatalogue(mCatalogue, token);
        return result;
    }


    /**
     * @api {POST} /m-catalogue/updateMCatalogue 更新目录
     * @apiVersion 1.0.0
     * @apiGroup 目录控制器
     * @apiName 更新目录
     * @apiParam (请求参数) {Number} mid
     * @apiParam (请求参数) {Number} uid
     * @apiParam (请求参数) {Number} cSort
     * @apiParam (请求参数) {String} cName
     * @apiParam (请求参数) {Array} musicList 音乐列表不存在与目录中，方便查询添加
     * @apiParam (请求参数) {Number} musicList.mid
     * @apiParam (请求参数) {String} musicList.mname
     * @apiParam (请求参数) {String} musicList.mauthor
     * @apiParam (请求参数) {Number} musicList.uid
     * @apiParam (请求参数) {String} musicList.murl
     * @apiParam (请求参数) {Number} musicList.msecond
     * @apiParam (请求参数) {String} musicList.mstatus
     * @apiParam (请求参数) {String} musicList.ispublish
     * @apiParam (请求参数) {String} musicList.coverby
     * @apiParam (请求参数) {String} musicList.mvurl
     * @apiParam (请求参数) {Number} musicList.praisecount
     * @apiParam (请求参数) {Number} musicList.praiseuserid
     * @apiParam (请求参数) {String} musicList.praiseusername
     * @apiParam (请求参数) {Number} musicList.listenuserid
     * @apiParam (请求参数) {Number} musicList.listencount
     * @apiParam (请求参数) {Number} musicList.downloadcount
     * @apiParam (请求参数) {Number} musicList.needlevel
     * @apiParam (请求参数) {Number} musicList.mType
     * @apiParam (请求参数) {Object} musicList.uploadDate
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * uid=7124&cName=CiCUYmNU&mid=8086&cSort=464&musicList={"msecond":7605,"listenuserid":4712,"mid":767,"mstatus":"NT","praisecount":9224,"mname":"DayZW3lX","mauthor":"lVc8g5","coverby":"EeWzp65","mType":3564,"uid":2746,"murl":"9mEhd2o","mvurl":"uF8","ispublish":"Vp","needlevel":5408,"praiseusername":"4R0qUq1u","listencount":2610,"downloadcount":8749,"praiseuserid":363}&token=bMY8A
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/updateMCatalogue")
    public Result updateMCatalogue(@RequestBody MCatalogue mCatalogue,@RequestHeader String token)
    {
        Result result = mCatalogueService.updateMCatalogue(mCatalogue, token);
        return result;
    }


    /**
     * @api {POST} /m-catalogue/deleteMCatalogue 删除目录
     * @apiVersion 1.0.0
     * @apiGroup 目录控制器
     * @apiName 删除目录
     * @apiParam (请求参数) {String} token
     * @apiParam (请求参数) {Number} id
     * @apiParamExample 请求参数示例
     * id=6609&token=KDKq9T
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/deleteMCatalogue")
    public Result deleteMCatalogue(@RequestHeader String token, @RequestBody Map map)
    {
        Integer id = (Integer) map.get("id");
        return mCatalogueService.deleteMCatalogue(token, id);
    }


    /**
     * @api {POST} /m-catalogue/selectMCatalogue 查询用户目录及其下面的音乐列表
     * @apiVersion 1.0.0
     * @apiGroup 目录控制器
     * @apiName selectMCatalogue
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * token=tYYLQ
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/selectMCatalogue")
    public Result selectMCatalogue(@RequestHeader String token)
    {
        return mCatalogueService.selectMCatalogue(token);
    }


    /**
     * @api {POST} /m-catalogue/selectSimpleMCatalogue 查询用户目录列表
     * @apiVersion 1.0.0
     * @apiGroup 目录控制器
     * @apiName selectSimpleMCatalogue
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * token=19u
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/selectSimpleMCatalogue")
    public Result selectSimpleMCatalogue(@RequestHeader String token)
    {
        return mCatalogueService.selectSimpleMCatalogue(token);
    }

}

